<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>2018/12/4</title>
    <script src="http://mockjs.com/dist/mock.js"></script>
   <script src="node_modules/jquery/dist/jquery.min.js"></script>
   <!--<script src="index.js"></script>-->
    <!--好的代码像粥一样,是得用时间和精力熬的。-->
</head>
<body>

</body>
<script>
    var template = {
        'title':'Syntax Demo',
        'string1|1-10':'★',
        'string2|3':'value',
        'number1|+1':100,
        'number2|1-100':100,
        'number3|1-100.1-10':1,
        'number4|123.1-10':1,
        'number5|123.3':1,
        'number6|123.10':1.123,

        'boolean1|1':true,//true和false出现概率个50%
        'boolean2|1-2':true,//前面为true后面跟的值为true概率为1/3,为false概率为2/3
        'object1|2-4':{
            '110000':'北京市',
            '120000': '天津市',
            '130000': '河北省',
            '140000': '山西省'
        },
        'object2|2':{
            '310000': '上海市',
            '320000': '江苏省',
            '330000': '浙江省',
            '340000': '安徽省'
        },
        'array1|1':['AMD','CMD','KMD','UMD'],
        'array2|1-10':['Mock.js'],
        'array3|3': ['Mock.js'],
        'function':function () {
            return this.title
        }
    };
    var data = Mock.mock(template);
    $('<pre>').text(JSON.stringify(data,null,4)).appendTo('body');
    // pre所见即所得，appendTo添加到body里
</script>
</html>
